package com.chenyi.leetcode.editor.cn;

import java.util.Arrays;

/**
 * [977]有序数组的平方
 * @author by chenyi
 * @className SquaresOfASortedArray
 * @date 2022-08-27 16:15:37
 */
public class SquaresOfASortedArray{
    public static void main(String[] args) {
        Solution solution = new SquaresOfASortedArray().new Solution();
        System.out.println(Arrays.toString(solution.sortedSquares(new int[]{1, 0, 22, 10, -1, -8})));
    }
    @SuppressWarnings("AlibabaCommentsMustBeJavadocFormat")
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] sortedSquares(int[] nums) {
        int[] ans = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            ans[i] = nums[i] * nums[i];
        }
        Arrays.sort(ans);
        return ans;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}
